package Physics;

public abstract class CollisionPrimitive {

	// The body that is represented by the primitive
	public RigidBody m_body ;

	// the offset of this primitiev from the given Rigid Body
	// i.e. the bounding volume may not match the exact
	// shape of the Rigid Body
	public Matrix4 m_offset ;
				
	// the result transform of the primite. Calculated
	// by combining the offset with the transform
	protected Matrix4 m_transform;

	protected PrimitiveType m_type;
				
	public CollisionPrimitive()
	{
		m_body = new RigidBody() ;
		m_offset = new Matrix4() ;
		m_transform = new Matrix4() ;
	}
		
	// calculate internals for the primitive
	public void calculateInternals()
	{
		// identify the transform matrix
		m_transform = m_body.getTransform() ;
			
		//multiply by the matrix offset
		m_transform.multiplyByMatrix(m_offset) ;
	}
				
	// for the sake of convenience, we allow access to
	// the axis vectors in the transform
	public Vector3 getAxis(int index)
	{
		return m_transform.getAxisVector(index);
	}
	// returns the result transformation of the primitive
	// with the offset combined and transformation of the
	// rigid body
	public Matrix4 getTransform()
	{
		return m_transform;
	}

	public PrimitiveType getPrimitiveType()
	{
			return m_type;
	}

}
